﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using HisGL.Net.Core;

namespace TestJMPro
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      richTextBox1.AppendText(CryptoHelper.MD5Encrypt32(textBox1.Text));
      richTextBox1.AppendText("\r\n");
    }

    private void button2_Click(object sender, EventArgs e)
    {
      richTextBox1.AppendText(CryptoHelper.SHA256Encrypt(textBox1.Text));
      richTextBox1.AppendText("\r\n");
    }

    private void button3_Click(object sender, EventArgs e)
    {
      richTextBox1.AppendText(GetStamp());
      richTextBox1.AppendText("\r\n");

      //TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
      //richTextBox1.AppendText(Convert.ToInt64(ts.TotalSeconds).ToString());
      //richTextBox1.AppendText("\r\n");

    }

    private string GetStamp()
    {
      long unixTimeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
      return unixTimeStamp.ToString();
      TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
      //return Convert.ToInt64(ts.TotalSeconds).ToString();
    }

    private void button4_Click(object sender, EventArgs e)
    {
      long unixTimeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
      richTextBox1.AppendText(unixTimeStamp.ToString());
    }

    private void button5_Click(object sender, EventArgs e)
    {
      TimeSpan ts = new DateTime(2025, 1, 1, 12, 23, 45, 0, DateTimeKind.Utc) - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
      Int64 iSS = Convert.ToInt64(ts.TotalSeconds);
      richTextBox1.AppendText(iSS.ToString());
      richTextBox1.AppendText("\r\n");

      DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Local).AddSeconds(iSS);
      richTextBox1.AppendText(dtDateTime.ToString());
      richTextBox1.AppendText("\r\n");
    }

    private void button6_Click(object sender, EventArgs e)
    {
      richTextBox1.AppendText(CryptoHelper.EncodeBase64("UTF-8",textBox1.Text));
      richTextBox1.AppendText("\r\n");

    }
  }
}
